﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using IntelligentEscalator.DAL;
using IntelligentEscalator.Models;

namespace IntelligentEscalator.BUS
{
    public class OrganizationBUS
    {
        public ResponseMessage QueryOrganization(OrganizationInfo organizationInfo)
        {
            ResponseMessage message = new ResponseMessage();

            OrganizationDAL da = new OrganizationDAL();
            List<OrganizationInfo> content = da.QueryOrganization(organizationInfo);

            message.errcode = 0;
            message.errmsg = "";
            message.data = content;
            message.total = da.QueryOrganizationCount(organizationInfo);

            return message;
        }

        public void AuthOrganization(AuthOrganizationInfo authOrganizationInfo)
        {
            OrganizationDAL organizationDAL = new OrganizationDAL();
            if (authOrganizationInfo.operateType == "add")
            {
                organizationDAL.AddOrganization(authOrganizationInfo);
            }
            else if (authOrganizationInfo.operateType == "update")
            {
                organizationDAL.EditOrganization(authOrganizationInfo);
            }
            else if (authOrganizationInfo.operateType == "delete")
            {
                organizationDAL.DelOrganization(authOrganizationInfo);
            }
        }
    }
}
